<template>
	<view class="p-30" v-if="isObjNone(list)">
		<view class="p-l-30 p-r-28 back-color-c radius-16 m-b-20">
			<view class="h-112 flex-between border-bottom-ee">
				<view class="flex">
					<image class="w-60 h-60 m-r-24" src="@/static/images/msg/msg1.png" /> 财务消息 <view class="badge" v-if="list.last_order_msg.unread_num > 0">
						{{ list.last_order_msg.unread_num }}
					</view>
				</view>
				<view class="font-24 color-a">{{ list.last_order_msg.create_time | date('yyyy-mm-dd') }}</view>
			</view>
			<view class="p-t-30 p-b-30">
				<view class="font-28 color-a line-1">
					<!--<text class="color-d m-r-8">[到账通知]</text>-->
					{{list.last_order_msg.title}}
				</view>
				<view class="font-28 color-b m-t-14" @click="details(list.last_order_msg.type)">查看更多</view>
			</view>
		</view>
		
		<view class="p-l-30 p-r-28 back-color-c radius-16 m-b-20">
			<view class="h-112 flex-between border-bottom-ee">
				<view class="flex">
					<image class="w-60 h-60 m-r-24" src="@/static/images/msg/msg.png" /> 系统消息 <view class="badge" v-if="list.last_system_msg.unread_num != 0">
						{{ list.last_system_msg.unread_num }}
					</view>
				</view>
				<view class="font-24 color-a">{{ list.last_system_msg.create_time | date('yyyy-mm-dd') }}</view>
			</view>
			<view class="p-t-30 p-b-30">
				<view class="font-28 color-a line-1">
					<!--<text class="color-d m-r-8">[合同提醒]</text>-->
					{{list.last_system_msg.title}}
				</view>
				<view class="font-28 color-b m-t-14" @click="details(list.last_system_msg.type)">查看更多</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		name: "msg",
		data() {
			return {
				value: 10,
				page: 1,
				status: 'nomore',
				list: {}
			}
		},
		onShow() {
			if (!this.isObjNone(this.user)) {
				// this.jump('/pages/user/login')
			} else {
				this.messageCenter()
			}
		},
		methods: {
			details(id) {
				uni.$u.route(`/pages/msg/msg-list?id=${id}`)
			},
			async messageCenter() {
				this.status = 'loading'
				const res = await this.$api.common.system('messageCenter')
				if (res.code === 200) {
					this.list = res.data
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	.badge {
		width: 40rpx;
		height: 40rpx;
		line-height: 40rpx;
		text-align: center;
		border-radius: 50%;
		background-color: $e;
		font-size: 24rpx;
		color: $c;
		margin-left: 4rpx;
		transform: translateY(-18rpx);
	}
</style>
